#include "Interpolation.h"

class F4:public Function
{
   public:
           double operator()(const double &x)const
           {
               if(x==0)
                   return 6.67;
               if(x==6)
                   return 17.3;
               if(x==10)
                   return 42.7;
               if(x==13)
                   return 37.3;
               if(x==17)
                   return 30.1;
               if(x==20)
                   return 29.3;
               if(x==28)
                   return 28.7;
               return 0;
           }
           double diff(const int &order,const double &x)const
           {
               return 0;
           }
};

class F5:public Function
{
   public:
           double operator()(const double &x)const
           {
               if(x==0)
                   return 6.67;
               if(x==6)
                   return 16.1;
               if(x==10)
                   return 18.9;
               if(x==13)
                   return 15.0;
               if(x==17)
                   return 10.6;
               if(x==20)
                   return 9.44;
               if(x==28)
                   return 8.89;
               return 0;
           }
           double diff(const int &order,const double &x)const
           {
               return 0;
           }
};

class G4:public Function
{
   public:
           double operator()(const double &x)const
           {
               if(x==0)
                   return 0;
               if(x==1)
                   return 6;
               if(x==2)
                   return 10;
               if(x==3)
                   return 13;
               if(x==4)
                   return 17;
               if(x==5)
                   return 20;
               if(x==6)
                   return 28;
               return 0;
           }
           double diff(const int &order,const double &x)const
           {
               return 0;
           }
};

int main()
{
     G4 g;
     F4 f1;
     F5 f2;
     Subroutine Sub1(f1,g,6),Sub2(f2,g,6);
     Sub1.generate();
     Sub2.generate();
     int i;
     
     for(i=29;i<=43;i++)
     {
         if(Sub1.Newtvalue(i)<0)
         {     
              cout<<"the sample 1 has died"<<endl;
              break;
         }
     }
     if(i==44)
         cout<<"the sample 1 has not died"<<endl;
     
     for(i=29;i<=43;i++)
     {
         if(Sub2.Newtvalue(i)<0)
         {     
              cout<<"the sample 2 has died"<<endl;
              break;
         }
     }
     if(i==44)
         cout<<"the sample 2 has not died"<<endl;
     
     for(int i=0;i<=6;i++)
     {
         cout<<Sub1.c[i]<<" ";
     }  
     cout<<endl;
     for(int i=0;i<=6;i++)
     {
         cout<<Sub2.c[i]<<" ";
     }  
     return 0;
}
